import QtQuick 2.0
import QtQuick.Layouts 1.12

Rectangle {


    id: root

    property int programSerial: 0
    property var programId: "0"
    property var programIsDefault: "0"
    property var programName: "name"
    property var programDuration: "20"
    property int programStep: 0
    property var programCreateDate: "2024-9-13"
    property var programMemo: "备注"

    color: "white"


    height: 40*dp
    width: parent.width

    MouseArea{
        anchors.fill: parent
        hoverEnabled: true
        onEntered: root.color = "#F2F9FF"
        onExited: root.color = "white"
    }

    Row{
        spacing: 8*dp
        anchors.fill: parent
        Item{  // 序号
            height: parent.height
            width: root.width * 0.08
            Text {
                anchors.centerIn: parent
                width: parent.width
                text: programSerial
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
        }
        Item{  // 编号
            height: parent.height
            width: root.width * 0.08
            Text {
                anchors.centerIn: parent
                width: parent.width - 10
                text: programId.toString()
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
        }
        Item{  // 程序名称
            height: parent.height
            width: root.width * 0.15
            Text {
                id: text_name
                anchors.centerIn: parent
                width: parent.width - 10
                text: programName
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
            Rectangle{
                visible: programIsDefault==="1"
                x: text_name.contentWidth/2 + parent.width/2 + 10; y: 9*dp
                height: 22*dp; width: 48*dp
                radius: 2
                color: "#F2F9FF"
                Text{
                    anchors.centerIn: parent
                    color: "#1677FF"
                    text: "默认"
                    font.pixelSize: config.fontsize-3
                }
            }
        }
        Item{  // 持续时间
            height: parent.height
            width: root.width * 0.15
            Text {
                anchors.centerIn: parent
                width: parent.width
                text: programDuration
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
        }
        Item{  // 创建时间
            height: parent.height
            width: root.width * 0.15
            Text {
                anchors.centerIn: parent
                width: parent.width
                text: programCreateDate
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
        }
        Item{  // 备注
            height: parent.height
            width: root.width * 0.2
            Text {
                text: programMemo
                width: parent.width
                anchors.centerIn : parent
                font.pixelSize: config.fontsize
                wrapMode: Text.WordWrap
                horizontalAlignment: TextInput.AlignHCenter
            }
        }
        Item{
            height: parent.height
            width: root.width * 0.12
            Item{
                height: parent.height
                width: root.width*0.04
                x: 0
                Text {
                    anchors.centerIn : parent
                    text: "删除"
                    font.pixelSize: config.fontsize
                    color: "#1677FF"
                }MouseArea{
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onReleased: {
                        pageProgram.deleteProgram(programId)
                    }
                }
            }
            Item{
                height: parent.height
                width: root.width*0.04
                x: parent.width*0.33
                Text {
                    anchors.centerIn : parent
                    text: programIsDefault==="1" ? "取消默认" : "默认"
                    font.pixelSize: config.fontsize
                    color: programIsDefault==="1" ? "#888888" : "#1677FF"
                }MouseArea{
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onReleased: {
                        pageProgram.setDefault(programId, programIsDefault==="1" ? "0" : "1")
                    }
                }
            }
            Item{
                height: parent.height
                width: root.width*0.04
                x: parent.width*0.66
                Text {
                    anchors.centerIn : parent
                    text: "查看"
                    font.pixelSize: config.fontsize
                    color: "#1677FF"
                }MouseArea{
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onReleased: {
                        pageProgram.tabDetailPage(programSerial-1)
                    }
                }
            }
        }



    }

    Rectangle{
        height: 1
        width: root.width
        color: "#EEEEEE"
        y: parent.height-1
    }



}
